/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view;

/**
 *
 * @author misja
 */
public class LocatieIndex extends javax.swing.JPanel {

    /**
     * Creates new form LocatieIndex
     */
    public LocatieIndex() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        btnVerwijderen = new javax.swing.JButton();
        btnBijwerken = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblLocatie = new javax.swing.JTable();
        btnToevoegen = new javax.swing.JButton();

        btnVerwijderen.setText("verwijderen");
        btnVerwijderen.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnVerwijderenActionPerformed(evt);
            }
        });

        btnBijwerken.setText("bijwerken");
        btnBijwerken.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBijwerkenActionPerformed(evt);
            }
        });

        tblLocatie.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane1.setViewportView(tblLocatie);

        btnToevoegen.setText("toevoegen");
        btnToevoegen.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnToevoegenActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 536, Short.MAX_VALUE)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(btnToevoegen)
                        .addComponent(btnVerwijderen)
                        .addComponent(btnBijwerken))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 403, Short.MAX_VALUE)
                    .addContainerGap()))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(btnToevoegen)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(btnVerwijderen)
                            .addGap(12, 12, 12)
                            .addComponent(btnBijwerken))
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 275, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addContainerGap(13, Short.MAX_VALUE)))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void btnVerwijderenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnVerwijderenActionPerformed
        int geselecteerdeRij = tblLocatie.getSelectedRow();
        String huisnummer = (String) tblLocatie.getModel().getValueAt(geselecteerdeRij, 3);
        String postcode = (String) tblLocatie.getModel().getValueAt(geselecteerdeRij, 4);

        new LocatieDialoog('v', huisnummer, postcode).setVisible(true);
        this.setVisible(false);
    }//GEN-LAST:event_btnVerwijderenActionPerformed

    private void btnBijwerkenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBijwerkenActionPerformed
        int geselecteerdeRij = tblLocatie.getSelectedRow();
        String huisnummer = (String) tblLocatie.getModel().getValueAt(geselecteerdeRij, 3);
        String postcode = (String) tblLocatie.getModel().getValueAt(geselecteerdeRij, 4);

        new LocatieDialoog('b', huisnummer, postcode).setVisible(true);
        this.setVisible(false);
    }//GEN-LAST:event_btnBijwerkenActionPerformed

    private void btnToevoegenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnToevoegenActionPerformed
        new LocatieDialoog('t', "", "").setVisible(true);
        this.setVisible(false);
    }//GEN-LAST:event_btnToevoegenActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnBijwerken;
    private javax.swing.JButton btnToevoegen;
    private javax.swing.JButton btnVerwijderen;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable tblLocatie;
    // End of variables declaration//GEN-END:variables
}
